home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-09 | 8.1 KB | 287 lines | [TEXT/MPS ] |
- {**********************************************************************************
- UDateTimeText.p
- Classes implementing the ability to enter dates and times as text in
- dialogs.
- **********************************************************************************}
-
- UNIT UDateTimeText;
-
- INTERFACE
- USES
- { • MacApp }
- UMacApp,
- UMacAppUtilities,
-
- { • building blocks }
- UTEView,
- UDialog,
-
- { • Implementation use }
- ToolUtils,
- Packages,
- Script,
-
- { • Application Units }
- UDateTimeUtilities,
- UValidText;
-
- CONST
- { The toolbox type DateForm is defined (IM v1 p504) as follows:
- DateForm = (shortDate, longDate, abbrevDate);
- These routines use the ordinal values (0, 1, 2) of these forms, plus
- the new form defDateForm ("Default Date Form", 255), which means "use
- the current global date form." }
- kDefDateForm = 255; { use the global date form value }
-
- kInvalidDateReasons = 701; { resID of the STR# resource containing
- reasons why date text wouldn't validate. }
-
- kInvalidTimeReasons = 702; { resID of the STR# resource containing
- reasons why time text wouldn't validate. }
-
-
-
- {###############################################################################
- Global Routines
- ###############################################################################}
-
- PROCEDURE InitUDateTimeText(
- theDateForm: DateForm);
-
- PROCEDURE SetDefaultDateForm(
- theDateForm: DateForm);
-
- FUNCTION GetDefaultDateForm
- :DateForm;
-
-
- TYPE
- {###############################################################################
- TDateEditText
- A TDateEditText view is one which is expected to contain a valid date
- string. This expectation is enforced by the Validate() method.
- ###############################################################################}
-
- DateTextTemplatePtr = ^DateTextTemplate;
- DateTextTemplate = RECORD
- theDateForm: INTEGER;
- END; { DateTextTemplate }
-
- TDateEditText = OBJECT(TValidText)
- fDateForm: INTEGER;
- fDateSecs: LongDateTime;
-
- PROCEDURE TDateEditText.IDateEditText(
- itsSuperView: TView;
- itsLocation: VPoint;
- itsSize: VPoint;
- strict: BOOLEAN;
- required: BOOLEAN;
- itsDateForm: INTEGER;
- itsDateSecs: LongDateTime);
-
- PROCEDURE TDateEditText.IRes(
- itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr);
- OVERRIDE;
-
- PROCEDURE TDateEditText.WRes(
- theResource: ViewRsrcHndl;
- VAR itsParams: Ptr);
- OVERRIDE;
-
- PROCEDURE TDateEditText.WriteRes(
- theResource: ViewRsrcHndl;
- VAR itsParams: Ptr);
- OVERRIDE;
-
- PROCEDURE TDateEditText.SetDateSecs(
- dateSecs: LongDateTime;
- redraw: BOOLEAN);
- { Set the date displayed by the item to the given date. Update the
- item's text to reflect the change. }
-
- PROCEDURE TDateEditText.SetDateForm(
- theDateForm: INTEGER;
- redraw: BOOLEAN);
- { Set the date form to the given value. Update the current text
- to reflect the change. }
-
- FUNCTION TDateEditText.GetDateSecs
- :LongDateTime;
-
- FUNCTION TDateEditText.GetDateForm
- :INTEGER;
- { Returns the value of fDateForm (which may be kDefDateForm). }
-
- FUNCTION TDateEditText.CurrentDateForm
- :DateForm;
- { Returns the DateForm with which the text in this item will be drawn.
- If fDateForm is in [0..2], then the value of fDateForm will be
- returned. If fDateForm = kDefDateForm, then the value of the
- global variable gDefaultDateForm will be returned. }
-
- PROCEDURE TDateEditText.UpdateText(
- redraw: BOOLEAN);
- OVERRIDE;
- { This routine replaces the text in the object with text that reflects
- the object's fDateSecs and fDateForm values. }
-
- FUNCTION TDateEditText.IsValid(
- VAR theText: Str255;
- VAR whyNot: INTEGER)
- :BOOLEAN;
- OVERRIDE;
- { If the text is valid, then this function returns TRUE, and whyNot
- is set to the value noErr (0). If the text is invalid, then the
- function returns FALSE and whyNot is set to a value indicating
- the reason why the text is invalid. }
-
- FUNCTION TDateEditText.HandleValidText(
- VAR theText: Str255)
- :LONGINT;
- OVERRIDE;
- { This routine updates SELF's internal instance variables to reflect
- the valid text. }
-
- PROCEDURE TDateEditText.ErrorToString(
- theError: INTEGER;
- VAR theString: Str255);
- OVERRIDE;
- { This routine sets theString to the string which best explains
- the given error. It is intended to be called only from
- ValidationErrorAlert(). }
-
- PROCEDURE TDateEditText.PrepareErrorAlert(
- VAR theText: Str255;
- theError: INTEGER);
- OVERRIDE;
- { The routine sets up the dialog that is displayed by
- ValidationErrorAlert(). }
-
- {$IFC qInspector}
- PROCEDURE TDateEditText.Fields(
- PROCEDURE DoToField(
- fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER));
- OVERRIDE;
- {$ENDC qInspector}
- END; { TDateEditText }
-
-
-
-
-
-
-
- {###############################################################################
- TTimeEditText
- A TTimeEditText view is one which is expected to contain a valid time
- string. This expectation is enforced by the Validate() method.
- ###############################################################################}
-
- TimeTextTemplatePtr = ^TimeTextTemplate;
- TimeTextTemplate = RECORD
- wantSeconds: BOOLEAN;
- reserved: BOOLEAN;
- END; { TimeTextTemplate }
-
- TTimeEditText = OBJECT(TValidText)
- fTimeSecs: LONGINT;
- fWantSeconds: BOOLEAN;
-
- PROCEDURE TTimeEditText.ITimeEditText(
- itsSuperView: TView;
- itsLocation: VPoint;
- itsSize: VPoint;
- strict: BOOLEAN;
- required: BOOLEAN;
- wantSeconds: BOOLEAN;
- itsTimeSecs: LONGINT);
-
- PROCEDURE TTimeEditText.IRes(
- itsDocument: TDocument;
- itsSuperView: TView;
- VAR itsParams: Ptr);
- OVERRIDE;
-
- PROCEDURE TTimeEditText.WRes(
- theResource: ViewRsrcHndl;
- VAR itsParams: Ptr);
- OVERRIDE;
-
- PROCEDURE TTimeEditText.WriteRes(
- theResource: ViewRsrcHndl;
- VAR itsParams: Ptr);
- OVERRIDE;
-
- PROCEDURE TTimeEditText.SetTimeSecs(
- timeSecs: LONGINT;
- redraw: BOOLEAN);
-
- PROCEDURE TTimeEditText.SetWantSeconds(
- wantSeconds: BOOLEAN;
- redraw: BOOLEAN);
-
- FUNCTION TTimeEditText.GetTimeSecs
- :LONGINT;
-
- FUNCTION TTimeEditText.GetWantSeconds
- :BOOLEAN;
-
- PROCEDURE TTimeEditText.UpdateText(
- redraw: BOOLEAN);
- OVERRIDE;
- { This routine replaces the text in the object with text that
- reflects the object's fTimeSecs and fWantSeconds values. }
-
- FUNCTION TTimeEditText.IsValid(
- VAR theText: Str255;
- VAR whyNot: INTEGER)
- :BOOLEAN;
- OVERRIDE;
- { If the text is valid, then this function returns TRUE, and whyNot
- is set to the value noErr (0). If the text is invalid, then the
- function returns FALSE and whyNot is set to a value indicating
- the reason why the text is invalid. }
-
- FUNCTION TTimeEditText.HandleValidText(
- VAR theText: Str255)
- :LONGINT;
- OVERRIDE;
- { This routine updates SELF's internal instance variables to reflect
- the valid text. }
-
- PROCEDURE TTimeEditText.ErrorToString(
- theError: INTEGER;
- VAR theString: Str255);
- OVERRIDE;
- { This routine sets theString to the string which best explains
- the given error. It is intended to be called only from
- ValidationErrorAlert(). }
-
- PROCEDURE TTimeEditText.PrepareErrorAlert(
- VAR theText: Str255;
- theError: INTEGER);
- OVERRIDE;
- { The routine sets up the dialog that is displayed by
- ValidationErrorAlert(). }
-
- { debugger stuff }
- {$IFC qInspector}
- PROCEDURE TTimeEditText.Fields(
- PROCEDURE DoToField(
- fieldName: Str255;
- fieldAddr: Ptr;
- fieldType: INTEGER));
- OVERRIDE;
- {$ENDC qInspector}
- END; { TTimeEditText }
-
- IMPLEMENTATION
-
- {$I UDateTimeText.inc1.p}
-
- END. { UDateTimeText.p }